var id = getQuery('id')
window.onload = function(){
    $('add').href = "/add.html?channelId="+id
    findByItem(1)
}
function findByItem(pageNO) {
    axios.get("/posts/selectByItem",{
        params:{
            pageNO,
            theme:$('theme').value,
            author:$('author').value,
            startDate:$('startDate').value,
            endDate:$('endDate').value,
            channelId:id
        }
    }).then(resp =>{
        console.log(pageNO)
        var info = resp.data
        var str = ""
        info.records.forEach(n =>{
            str += `<tr><td><a href="/replay.html?id=${n.id}">${n.theme}</a></td>
            <td>${n.writer.userName}</td><td>${n.replayNum}</td><td>${n.wDate}</td></tr>`
        })
        $('postsdata').innerHTML = str;
        var cutStr = ""
        for (let i = 1; i <= info.pages; i++) {
            cutStr += `<a style="margin-left: 10px" href="javascript:findByItem(${i})">${i}</a>`
        }
        $('cutDiv').innerHTML = cutStr;
    })
}